/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Bussiness;
import DatabaseAccess.DBHelper;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
/**
 *
 * @author Mrhung
 */
public class PhieuNhap {
    private String MaHang;
    private String SoPhieuNhap;
    private int SoLuongYeuCau;
    private int SoLuongThuc;
    private String NgayNhap;
    DBHelper conn = new DBHelper();

    /**
     * @return the MaHang
     */
    public String getMaHang() {
        return MaHang;
    }

    /**
     * @param MaHang the MaHang to set
     */
    public void setMaHang(String MaHang) {
        this.MaHang = MaHang;
    }

    /**
     * @return the SoPhieuNhap
     */
    public String getSoPhieuNhap() {
        return SoPhieuNhap;
    }

    /**
     * @param SoPhieuNhap the SoPhieuNhap to set
     */
    public void setSoPhieuNhap(String SoPhieuNhap) {
        this.SoPhieuNhap = SoPhieuNhap;
    }

    /**
     * @return the SoLuongYeuCau
     */
    public int getSoLuongYeuCau() {
        return SoLuongYeuCau;
    }

    /**
     * @param SoLuongYeuCau the SoLuongYeuCau to set
     */
    public void setSoLuongYeuCau(int SoLuongYeuCau) {
        this.SoLuongYeuCau = SoLuongYeuCau;
    }

    /**
     * @return the SoLuongThuc
     */
    public int getSoLuongThuc() {
        return SoLuongThuc;
    }

    /**
     * @param SoLuongThuc the SoLuongThuc to set
     */
    public void setSoLuongThuc(int SoLuongThuc) {
        this.SoLuongThuc = SoLuongThuc;
    }

    /**
     * @return the NgayNhap
     */
    public String getNgayNhap() {
        return NgayNhap;
    }

    /**
     * @param NgayNhap the NgayNhap to set
     */
    public void setNgayNhap(String NgayNhap) {
        this.NgayNhap = NgayNhap;
    }
    public PhieuNhap(){
        
    }
    public PhieuNhap(String MaHang,String SoPhieuNhap,int SoLuongYeuCau,int SoLuongThuc,String NgayNhap){
        this.setMaHang(MaHang);
        this.setSoPhieuNhap(SoPhieuNhap);
        this.setSoLuongYeuCau(SoLuongYeuCau);
        this.setSoLuongThuc(SoLuongThuc);
        this.setNgayNhap(NgayNhap);
     }
     public int InsertPhieuNhap(PhieuNhap a) throws SQLException
    {
        int i = 0;
        try{
            Vector v = new Vector();
            v.add(a.getMaHang());
            v.add(a.getSoPhieuNhap());
            v.add(a.getSoLuongYeuCau());
            v.add(a.getSoLuongThuc());
            v.add(a.getNgayNhap());
            i=conn.executeUpdate("sp_insertNhapHang",v);
        }catch(SQLException ex){}
        return i;
    }
     public int UpdatePhieuNhap(PhieuNhap a) throws SQLException
    {
        DBHelper obj =new DBHelper();
        int i = 0;
        try{
            Vector v = new Vector();
            v.add(a.getMaHang());
            v.add(a.getSoPhieuNhap());
            v.add(a.getSoLuongYeuCau());
            v.add(a.getSoLuongThuc());
            v.add(a.getNgayNhap());
            i=obj.executeUpdate("sp_updateNhapHang",v);
        }catch(SQLException ex){}
        return i;
    }
     public int DelPhieuNhap(String SoPhieuNhap) throws SQLException
    {
        int i=0;
        try
        {
            Vector paramList=new Vector();
            paramList.add(SoPhieuNhap);            
            i=conn.executeUpdate("sp_DellNhapHang",paramList);
        }
        catch(SQLException sqlex)
        {
            System.out.println(sqlex);
        }
        return i;
    }
     public Vector getAllPhieuNhap() throws SQLException 
    {
        Vector v = new Vector();
        try 
        {
            ResultSet rs = conn.executeQuery("sp_getAllNhapHang");
            while(rs.next())
            {                  
                PhieuNhap b = new PhieuNhap();
                b.setSoPhieuNhap(rs.getString(2));
                b.setMaHang(rs.getString(1));
                b.setSoLuongYeuCau(rs.getInt(3));
                b.setSoLuongThuc(rs.getInt(4));
                b.setNgayNhap(rs.getString(5));
                v.add(b);                         
            }
        } 
        catch(SQLException sqle) 
        {            
        }
        return v;
    }
     public Vector getPN_SoPhieuNhap(String SoPhieuNhap) throws SQLException
    {
        Vector v = new Vector();
        Vector v1 = new Vector();
        v1.add(SoPhieuNhap);
        try{
            ResultSet rs = conn.executeQuery("sp_getSoPhieu", v1);
            while(rs.next()){
                PhieuNhap b = new PhieuNhap();
                b.setMaHang(rs.getString(1));
                b.setSoPhieuNhap(rs.getString(2));
                b.setSoLuongYeuCau(rs.getInt(3));
                b.setSoLuongThuc(rs.getInt(4));
                b.setNgayNhap(rs.getString(5));

                v.add(b);
            }
        }catch(SQLException sqle) {}
        return v; 
    }
     public Vector getPhieuNhapThang1() throws SQLException
    {
        Vector v = new Vector();
        try 
        {
            ResultSet rs = conn.executeQuery("Thang1");
            while(rs.next())
            {                  
                PhieuNhap b = new PhieuNhap();
                b.setSoPhieuNhap(rs.getString(2));
                b.setMaHang(rs.getString(1));
                b.setSoLuongYeuCau(rs.getInt(3));
                b.setSoLuongThuc(rs.getInt(4));
                b.setNgayNhap(rs.getString(5));
                v.add(b);                         
            }
        } 
        catch(SQLException sqle) 
        {            
        }
        return v;
    }
     public Vector getPhieuNhapThang2() throws SQLException
    {
        Vector v = new Vector();
        try 
        {
            ResultSet rs = conn.executeQuery("Thang2");
            while(rs.next())
            {                  
                PhieuNhap b = new PhieuNhap();
                b.setSoPhieuNhap(rs.getString(2));
                b.setMaHang(rs.getString(1));
                b.setSoLuongYeuCau(rs.getInt(3));
                b.setSoLuongThuc(rs.getInt(4));
                b.setNgayNhap(rs.getString(5));
                v.add(b);                         
            }
        } 
        catch(SQLException sqle) 
        {            
        }
        return v;
    }
      public Vector getPhieuNhapThang3() throws SQLException
    {
        Vector v = new Vector();
        try 
        {
            ResultSet rs = conn.executeQuery("Thang3");
            while(rs.next())
            {                  
                PhieuNhap b = new PhieuNhap();
                b.setSoPhieuNhap(rs.getString(2));
                b.setMaHang(rs.getString(1));
                b.setSoLuongYeuCau(rs.getInt(3));
                b.setSoLuongThuc(rs.getInt(4));
                b.setNgayNhap(rs.getString(5));
                v.add(b);                         
            }
        } 
        catch(SQLException sqle) 
        {            
        }
        return v;
    }
     public Vector getPhieuNhapThang4() throws SQLException
    {
        Vector v = new Vector();
        try 
        {
            ResultSet rs = conn.executeQuery("Thang4");
            while(rs.next())
            {                  
                PhieuNhap b = new PhieuNhap();
                b.setSoPhieuNhap(rs.getString(2));
                b.setMaHang(rs.getString(1));
                b.setSoLuongYeuCau(rs.getInt(3));
                b.setSoLuongThuc(rs.getInt(4));
                b.setNgayNhap(rs.getString(5));
                v.add(b);                         
            }
        } 
        catch(SQLException sqle) 
        {            
        }
        return v;
    }
     public Vector getPhieuNhapThang5() throws SQLException
    {
        Vector v = new Vector();
        try 
        {
            ResultSet rs = conn.executeQuery("Thang5");
            while(rs.next())
            {                  
                PhieuNhap b = new PhieuNhap();
                b.setSoPhieuNhap(rs.getString(2));
                b.setMaHang(rs.getString(1));
                b.setSoLuongYeuCau(rs.getInt(3));
                b.setSoLuongThuc(rs.getInt(4));
                b.setNgayNhap(rs.getString(5));
                v.add(b);                         
            }
        } 
        catch(SQLException sqle) 
        {            
        }
        return v;
    }
     public Vector getPhieuNhapThang6() throws SQLException
    {
        Vector v = new Vector();
        try 
        {
            ResultSet rs = conn.executeQuery("Thang6");
            while(rs.next())
            {                  
                PhieuNhap b = new PhieuNhap();
                b.setSoPhieuNhap(rs.getString(2));
                b.setMaHang(rs.getString(1));
                b.setSoLuongYeuCau(rs.getInt(3));
                b.setSoLuongThuc(rs.getInt(4));
                b.setNgayNhap(rs.getString(5));
                v.add(b);                         
            }
        } 
        catch(SQLException sqle) 
        {            
        }
        return v;
    }
     public Vector getPhieuNhapThang7() throws SQLException
    {
        Vector v = new Vector();
        try 
        {
            ResultSet rs = conn.executeQuery("Thang7");
            while(rs.next())
            {                  
                PhieuNhap b = new PhieuNhap();
                b.setSoPhieuNhap(rs.getString(2));
                b.setMaHang(rs.getString(1));
                b.setSoLuongYeuCau(rs.getInt(3));
                b.setSoLuongThuc(rs.getInt(4));
                b.setNgayNhap(rs.getString(5));
                v.add(b);                         
            }
        } 
        catch(SQLException sqle) 
        {            
        }
        return v;
    }
     public Vector getPhieuNhapThang8() throws SQLException
    {
        Vector v = new Vector();
        try 
        {
            ResultSet rs = conn.executeQuery("Thang8");
            while(rs.next())
            {                  
                PhieuNhap b = new PhieuNhap();
                b.setSoPhieuNhap(rs.getString(2));
                b.setMaHang(rs.getString(1));
                b.setSoLuongYeuCau(rs.getInt(3));
                b.setSoLuongThuc(rs.getInt(4));
                b.setNgayNhap(rs.getString(5));
                v.add(b);                         
            }
        } 
        catch(SQLException sqle) 
        {            
        }
        return v;
    }
     public Vector getPhieuNhapThang9() throws SQLException
    {
        Vector v = new Vector();
        try 
        {
            ResultSet rs = conn.executeQuery("Thang9");
            while(rs.next())
            {                  
                PhieuNhap b = new PhieuNhap();
                b.setSoPhieuNhap(rs.getString(2));
                b.setMaHang(rs.getString(1));
                b.setSoLuongYeuCau(rs.getInt(3));
                b.setSoLuongThuc(rs.getInt(4));
                b.setNgayNhap(rs.getString(5));
                v.add(b);                         
            }
        } 
        catch(SQLException sqle) 
        {            
        }
        return v;
    }
     public Vector getPhieuNhapThang10() throws SQLException
    {
        Vector v = new Vector();
        try 
        {
            ResultSet rs = conn.executeQuery("Thang10");
            while(rs.next())
            {                  
                PhieuNhap b = new PhieuNhap();
                b.setSoPhieuNhap(rs.getString(2));
                b.setMaHang(rs.getString(1));
                b.setSoLuongYeuCau(rs.getInt(3));
                b.setSoLuongThuc(rs.getInt(4));
                b.setNgayNhap(rs.getString(5));
                v.add(b);                         
            }
        } 
        catch(SQLException sqle) 
        {            
        }
        return v;
    }
     public Vector getPhieuNhapThang11() throws SQLException
    {
        Vector v = new Vector();
        try 
        {
            ResultSet rs = conn.executeQuery("Thang11");
            while(rs.next())
            {                  
                PhieuNhap b = new PhieuNhap();
                b.setSoPhieuNhap(rs.getString(2));
                b.setMaHang(rs.getString(1));
                b.setSoLuongYeuCau(rs.getInt(3));
                b.setSoLuongThuc(rs.getInt(4));
                b.setNgayNhap(rs.getString(5));
                v.add(b);                         
            }
        } 
        catch(SQLException sqle) 
        {            
        }
        return v;
    }
     public Vector getPhieuNhapThang12() throws SQLException
    {
        Vector v = new Vector();
        try 
        {
            ResultSet rs = conn.executeQuery("Thang12");
            while(rs.next())
            {                  
                PhieuNhap b = new PhieuNhap();
                b.setSoPhieuNhap(rs.getString(2));
                b.setMaHang(rs.getString(1));
                b.setSoLuongYeuCau(rs.getInt(3));
                b.setSoLuongThuc(rs.getInt(4));
                b.setNgayNhap(rs.getString(5));
                v.add(b);                         
            }
        } 
        catch(SQLException sqle) 
        {            
        }
        return v;
    }
}
